/*
 * (c) Copyright Ascensio System SIA 2010-2019
 *
 * This program is a free software product. You can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public License (AGPL)
 * version 3 as published by the Free Software Foundation. In accordance with
 * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
 * that Ascensio System SIA expressly excludes the warranty of non-infringement
 * of any third-party rights.
 *
 * This program is distributed WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR  PURPOSE. For
 * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
 *
 * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
 * street, Riga, Latvia, EU, LV-1050.
 *
 * The  interactive user interfaces in modified source and object code versions
 * of the Program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU AGPL version 3.
 *
 * Pursuant to Section 7(b) of the License you must retain the original Product
 * logo when distributing the program. Pursuant to Section 7(e) we decline to
 * grant you any rights under trademark law for use of our trademarks.
 *
 * All the Product's GUI elements, including illustrations and icon sets, as
 * well as technical writing content are licensed under the terms of the
 * Creative Commons Attribution-ShareAlike 4.0 International. See the License
 * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
 *
 */

"use strict";

(function(window, undefined){

var CAscColorScheme = AscCommon.CAscColorScheme;
var CColor = AscCommon.CColor;

var g_oAutoShapesGroups = [
    "Basic shapes",
    "Figured arrows",
    "Math",
    "Charts",
    "Stars & Ribbons",
    "Callouts",
    "Buttons",
    "Rectangles",
    "Lines"
];

var autoShapes = [
	[
		"textRect", "rect", "ellipse", "triangle", "rtTriangle", "parallelogram", "trapezoid", "diamond", "pentagon", "hexagon",  "heptagon",
		"octagon", "decagon", "dodecagon", "pie", "chord", "teardrop", "frame", "halfFrame", "corner", "diagStripe", "plus", "plaque",
		"can", "cube", "bevel", "donut", "noSmoking", "blockArc", "foldedCorner", "smileyFace", "heart", "lightningBolt", "sun",
		"moon", "cloud", "arc", "bracePair", "leftBracket", "rightBracket", "leftBrace", "rightBrace"
	],
	[
		"rightArrow", "leftArrow", "upArrow", "downArrow", "leftRightArrow", "upDownArrow", "quadArrow", "leftRightUpArrow", "bentArrow",
		"uturnArrow", "leftUpArrow", "bentUpArrow", "curvedRightArrow", "curvedLeftArrow", "curvedUpArrow", "curvedDownArrow", "stripedRightArrow",
		"notchedRightArrow", "homePlate", "chevron", "rightArrowCallout", "downArrowCallout", "leftArrowCallout", "upArrowCallout",
		"leftRightArrowCallout", "quadArrowCallout", "circularArrow"
	],
	[
        "mathPlus", "mathMinus", "mathMultiply", "mathDivide", "mathEqual", "mathNotEqual"
	],
	[
		"flowChartProcess", "flowChartAlternateProcess", "flowChartDecision", "flowChartInputOutput", "flowChartPredefinedProcess",
		"flowChartInternalStorage", "flowChartDocument", "flowChartMultidocument", "flowChartTerminator", "flowChartPreparation",
		"flowChartManualInput", "flowChartManualOperation", "flowChartConnector", "flowChartOffpageConnector", "flowChartPunchedCard",
		"flowChartPunchedTape", "flowChartSummingJunction", "flowChartOr", "flowChartCollate", "flowChartSort", "flowChartExtract",
		"flowChartMerge", "flowChartOnlineStorage", "flowChartDelay", "flowChartMagneticTape", "flowChartMagneticDisk", "flowChartMagneticDrum", "flowChartDisplay"
	],
	[
		"irregularSeal1", "irregularSeal2", "star4", "star5", "star6", "star7", "star8", "star10", "star12", "star16", "star24", "star32",
		"ribbon2", "ribbon", "ellipseRibbon2", "ellipseRibbon", "verticalScroll", "horizontalScroll", "wave", "doubleWave"
	],
	[
		"wedgeRectCallout", "wedgeRoundRectCallout", "wedgeEllipseCallout", "cloudCallout", "borderCallout1", "borderCallout2", "borderCallout3",
		"accentCallout1", "accentCallout2", "accentCallout3", "callout1", "callout2", "callout3", "accentBorderCallout1", "accentBorderCallout2", "accentBorderCallout3"
	],
	[
		"actionButtonBackPrevious", "actionButtonForwardNext", "actionButtonBeginning", "actionButtonEnd", "actionButtonHome", "actionButtonInformation",
		"actionButtonReturn", "actionButtonMovie", "actionButtonDocument", "actionButtonSound", "actionButtonHelp", "actionButtonBlank"
	],
	[
		"rect", "roundRect", "snip1Rect", "snip2SameRect", "snip2DiagRect", "snipRoundRect", "round1Rect", "round2SameRect", "round2DiagRect"
	],
	[
		"line", "lineWithArrow", "lineWithTwoArrows", "bentConnector5", "bentConnector5WithArrow", "bentConnector5WithTwoArrows", "curvedConnector3",
		"curvedConnector3WithArrow", "curvedConnector3WithTwoArrows", "spline", "polyline1", "polyline2"
	]
];

var g_oAutoShapesTypes = [];

for (var i = 0, length = autoShapes.length; i < length; i++)
{
	g_oAutoShapesTypes[i] = [];
	for (var j = 0, length_group = autoShapes[i].length; j < length_group; j++)
	{
        g_oAutoShapesTypes[i].push({ "Type" : autoShapes[i][j] });
	}
}

var g_oStandartColors = [
    {R: 0xC0, G: 0x00, B: 0x00},
    {R: 0xFF, G: 0x00, B: 0x00},
    {R: 0xFF, G: 0xC0, B: 0x00},
    {R: 0xFF, G: 0xFF, B: 0x00},
    {R: 0x92, G: 0xD0, B: 0x50},
    {R: 0x00, G: 0xB0, B: 0x50},
    {R: 0x00, G: 0xB0, B: 0xF0},
    {R: 0x00, G: 0x70, B: 0xC0},
    {R: 0x00, G: 0x20, B: 0x60},
    {R: 0x70, G: 0x30, B: 0xA0}
];

var g_oThemeColorsDefaultModsWord = [
    [
        { name : "wordShade", val : 0xF2 },
        { name : "wordShade", val : 0xD9 },
        { name : "wordShade", val : 0xBF },
        { name : "wordShade", val : 0xA6 },
        { name : "wordShade", val : 0x80 }
    ],
    [
        { name : "wordShade", val : 0xE6 },
        { name : "wordShade", val : 0xBF },
        { name : "wordShade", val : 0x80 },
        { name : "wordShade", val : 0x40 },
        { name : "wordShade", val : 0x1A }
    ],
    [
        { name : "wordTint", val : 0x33 },
        { name : "wordTint", val : 0x66 },
        { name : "wordTint", val : 0x99 },
        { name : "wordShade", val : 0xBF },
        { name : "wordShade", val : 0x80 }
    ],
    [
        { name : "wordTint", val : 0x1A },
        { name : "wordTint", val : 0x40 },
        { name : "wordTint", val : 0x80 },
        { name : "wordTint", val : 0xBF },
        { name : "wordTint", val : 0xE6 }
    ],
    [
        { name : "wordTint", val : 0x80 },
        { name : "wordTint", val : 0xA6 },
        { name : "wordTint", val : 0xBF },
        { name : "wordTint", val : 0xD9 },
        { name : "wordTint", val : 0xF2 }
    ]
];

var g_oThemeColorsDefaultModsPowerPoint = [
    [
        { lumMod : 95000, lumOff : -1 },
        { lumMod : 85000, lumOff : -1 },
        { lumMod : 75000, lumOff : -1 },
        { lumMod : 65000, lumOff : -1 },
        { lumMod : 50000, lumOff : -1 }
    ],
    [
        { lumMod : 90000, lumOff : -1 },
        { lumMod : 75000, lumOff : -1 },
        { lumMod : 50000, lumOff : -1 },
        { lumMod : 25000, lumOff : -1 },
        { lumMod : 10000, lumOff : -1 }
    ],
    [
        { lumMod : 20000, lumOff : 80000 },
        { lumMod : 40000, lumOff : 60000 },
        { lumMod : 60000, lumOff : 40000 },
        { lumMod : 75000, lumOff : -1 },
        { lumMod : 50000, lumOff : -1 }
    ],
    [
        { lumMod : 10000, lumOff : 90000 },
        { lumMod : 25000, lumOff : 75000 },
        { lumMod : 50000, lumOff : 50000 },
        { lumMod : 75000, lumOff : 25000 },
        { lumMod : 90000, lumOff : 10000 }
    ],
    [
        { lumMod : 50000, lumOff : 50000 },
        { lumMod : 65000, lumOff : 35000 },
        { lumMod : 75000, lumOff : 25000 },
        { lumMod : 85000, lumOff : 15000 },
        { lumMod : 90000, lumOff : 5000 }
    ]
];

/* 0..4 */
function GetDefaultColorModsIndex(r, g, b)
{
    var L = (Math.max(r, Math.max(g, b)) + Math.min(r, Math.min(g, b))) / 2;
    L /= 255;
    if (L == 1)
        return 0;
    if (L >= 0.8)
        return 1;
    if (L >= 0.2)
        return 2;
    if (L > 0)
        return 3;
    return 4;
}

/* 0 - ppt, 1 - word, 2 - excel */
function GetDefaultMods(r, g, b, pos, editor_id)
{
    if (pos < 1 || pos > 5)
        return [];

    var index = GetDefaultColorModsIndex(r, g, b);
    var _obj, _mods = [], _mod;

    if (editor_id == 0)
    {
        _obj = g_oThemeColorsDefaultModsPowerPoint[index][pos - 1];

        if (_obj.lumMod !== -1)
        {
            _mod = new AscFormat.CColorMod();
            _mod["name"] = "lumMod";
            _mod["val"] = _obj.lumMod;
            _mods.push(_mod);
        }
        if (_obj.lumOff !== -1)
        {
            _mod = new AscFormat.CColorMod();
            _mod.name = "lumOff";
            _mod.val = _obj.lumOff;
            _mods.push(_mod);
        }

        return _mods;
    }
    if (editor_id == 1)
    {
        _obj = g_oThemeColorsDefaultModsWord[index][pos - 1];

        _mod = new AscFormat.CColorMod();
        _mod.name = _obj.name;
        _mod.val = _obj.val /** 100000 / 255) >> 0*/;
        _mods.push(_mod);

        return _mods;
    }
    // TODO: excel
    return [];
}

	var g_oUserColorScheme = [];
	var elem;
	elem = new CAscColorScheme();
	elem.name = 'New Office';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(0xFF, 0xFF, 0xFF));
	elem.putColor(new CColor(0x44, 0x54, 0x6A));
	elem.putColor(new CColor(0xE7, 0xE6, 0xE6));
	elem.putColor(new CColor(0x5B, 0x9B, 0xD5));
	elem.putColor(new CColor(0xED, 0x7D, 0x31));
	elem.putColor(new CColor(0xA5, 0xA5, 0xA5));
	elem.putColor(new CColor(0xFF, 0xC0, 0x00));
	elem.putColor(new CColor(0x44, 0x72, 0xC4));
	elem.putColor(new CColor(0x70, 0xAD, 0x47));
	elem.putColor(new CColor(0x05, 0x63, 0xC1));
	elem.putColor(new CColor(0x95, 0x4F, 0x72));
	g_oUserColorScheme.push(elem);

	elem = new CAscColorScheme();
	elem.name = 'Office';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(31, 73, 125));
	elem.putColor(new CColor(238, 236, 225));
	elem.putColor(new CColor(79, 129, 189));
	elem.putColor(new CColor(192, 80, 77));
	elem.putColor(new CColor(155, 187, 89));
	elem.putColor(new CColor(128, 100, 162));
	elem.putColor(new CColor(75, 172, 198));
	elem.putColor(new CColor(247, 150, 70));
	elem.putColor(new CColor(0, 0, 255));
	elem.putColor(new CColor(128, 0, 128));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Grayscale';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(248, 248, 248));
	elem.putColor(new CColor(221, 221, 221));
	elem.putColor(new CColor(178, 178, 178));
	elem.putColor(new CColor(150, 150, 150));
	elem.putColor(new CColor(128, 128, 128));
	elem.putColor(new CColor(95, 95, 95));
	elem.putColor(new CColor(77, 77, 77));
	elem.putColor(new CColor(95, 95, 95));
	elem.putColor(new CColor(145, 145, 145));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Apex';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(105, 103, 109));
	elem.putColor(new CColor(201, 194, 209));
	elem.putColor(new CColor(206, 185, 102));
	elem.putColor(new CColor(156, 176, 132));
	elem.putColor(new CColor(107, 177, 201));
	elem.putColor(new CColor(101, 133, 207));
	elem.putColor(new CColor(126, 107, 201));
	elem.putColor(new CColor(163, 121, 187));
	elem.putColor(new CColor(65, 0, 130));
	elem.putColor(new CColor(147, 41, 104));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Aspect';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(50, 50, 50));
	elem.putColor(new CColor(227, 222, 209));
	elem.putColor(new CColor(240, 127, 9));
	elem.putColor(new CColor(159, 41, 54));
	elem.putColor(new CColor(27, 88, 124));
	elem.putColor(new CColor(78, 133, 66));
	elem.putColor(new CColor(96, 72, 120));
	elem.putColor(new CColor(193, 152, 89));
	elem.putColor(new CColor(107, 159, 37));
	elem.putColor(new CColor(178, 107, 2));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Civic';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(100, 107, 134));
	elem.putColor(new CColor(197, 209, 215));
	elem.putColor(new CColor(209, 99, 73));
	elem.putColor(new CColor(204, 180, 0));
	elem.putColor(new CColor(140, 173, 174));
	elem.putColor(new CColor(140, 123, 112));
	elem.putColor(new CColor(143, 176, 140));
	elem.putColor(new CColor(209, 144, 73));
	elem.putColor(new CColor(0, 163, 214));
	elem.putColor(new CColor(105, 79, 7));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Concourse';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(70, 70, 70));
	elem.putColor(new CColor(222, 245, 250));
	elem.putColor(new CColor(45, 162, 191));
	elem.putColor(new CColor(218, 31, 40));
	elem.putColor(new CColor(235, 100, 27));
	elem.putColor(new CColor(57, 99, 157));
	elem.putColor(new CColor(71, 75, 120));
	elem.putColor(new CColor(125, 60, 74));
	elem.putColor(new CColor(255, 129, 25));
	elem.putColor(new CColor(68, 185, 232));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Equity';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(105, 100, 100));
	elem.putColor(new CColor(233, 229, 220));
	elem.putColor(new CColor(211, 72, 23));
	elem.putColor(new CColor(155, 45, 31));
	elem.putColor(new CColor(162, 142, 106));
	elem.putColor(new CColor(149, 98, 81));
	elem.putColor(new CColor(145, 132, 133));
	elem.putColor(new CColor(133, 93, 93));
	elem.putColor(new CColor(204, 153, 0));
	elem.putColor(new CColor(150, 169, 169));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Flow';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(4, 97, 123));
	elem.putColor(new CColor(219, 245, 249));
	elem.putColor(new CColor(15, 111, 198));
	elem.putColor(new CColor(0, 157, 217));
	elem.putColor(new CColor(11, 208, 217));
	elem.putColor(new CColor(16, 207, 155));
	elem.putColor(new CColor(124, 202, 98));
	elem.putColor(new CColor(165, 194, 73));
	elem.putColor(new CColor(244, 145, 0));
	elem.putColor(new CColor(133, 223, 208));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Foundry';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(103, 106, 85));
	elem.putColor(new CColor(234, 235, 222));
	elem.putColor(new CColor(114, 163, 118));
	elem.putColor(new CColor(176, 204, 176));
	elem.putColor(new CColor(168, 205, 215));
	elem.putColor(new CColor(192, 190, 175));
	elem.putColor(new CColor(206, 197, 151));
	elem.putColor(new CColor(232, 183, 183));
	elem.putColor(new CColor(219, 83, 83));
	elem.putColor(new CColor(144, 54, 56));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Median';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(119, 95, 85));
	elem.putColor(new CColor(235, 221, 195));
	elem.putColor(new CColor(148, 182, 210));
	elem.putColor(new CColor(221, 128, 71));
	elem.putColor(new CColor(165, 171, 129));
	elem.putColor(new CColor(216, 178, 92));
	elem.putColor(new CColor(123, 167, 157));
	elem.putColor(new CColor(150, 140, 140));
	elem.putColor(new CColor(247, 182, 21));
	elem.putColor(new CColor(112, 68, 4));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Metro';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(78, 91, 111));
	elem.putColor(new CColor(214, 236, 255));
	elem.putColor(new CColor(127, 209, 59));
	elem.putColor(new CColor(234, 21, 122));
	elem.putColor(new CColor(254, 184, 10));
	elem.putColor(new CColor(0, 173, 220));
	elem.putColor(new CColor(115, 138, 200));
	elem.putColor(new CColor(26, 179, 159));
	elem.putColor(new CColor(235, 136, 3));
	elem.putColor(new CColor(95, 119, 145));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Module';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(90, 99, 120));
	elem.putColor(new CColor(212, 212, 214));
	elem.putColor(new CColor(240, 173, 0));
	elem.putColor(new CColor(96, 181, 204));
	elem.putColor(new CColor(230, 108, 125));
	elem.putColor(new CColor(107, 183, 109));
	elem.putColor(new CColor(232, 134, 81));
	elem.putColor(new CColor(198, 72, 71));
	elem.putColor(new CColor(22, 139, 186));
	elem.putColor(new CColor(104, 0, 0));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Opulent';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(177, 63, 154));
	elem.putColor(new CColor(244, 231, 237));
	elem.putColor(new CColor(184, 61, 104));
	elem.putColor(new CColor(172, 102, 187));
	elem.putColor(new CColor(222, 108, 54));
	elem.putColor(new CColor(249, 182, 57));
	elem.putColor(new CColor(207, 109, 164));
	elem.putColor(new CColor(250, 141, 61));
	elem.putColor(new CColor(255, 222, 102));
	elem.putColor(new CColor(212, 144, 197));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Oriel';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(87, 95, 109));
	elem.putColor(new CColor(255, 243, 157));
	elem.putColor(new CColor(254, 134, 55));
	elem.putColor(new CColor(117, 152, 217));
	elem.putColor(new CColor(179, 44, 22));
	elem.putColor(new CColor(245, 205, 45));
	elem.putColor(new CColor(174, 186, 213));
	elem.putColor(new CColor(119, 124, 132));
	elem.putColor(new CColor(210, 97, 28));
	elem.putColor(new CColor(59, 67, 91));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Origin';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(70, 70, 83));
	elem.putColor(new CColor(221, 233, 236));
	elem.putColor(new CColor(114, 124, 163));
	elem.putColor(new CColor(159, 184, 205));
	elem.putColor(new CColor(210, 218, 122));
	elem.putColor(new CColor(250, 218, 122));
	elem.putColor(new CColor(184, 132, 114));
	elem.putColor(new CColor(142, 115, 106));
	elem.putColor(new CColor(178, 146, 202));
	elem.putColor(new CColor(107, 86, 128));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Paper';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(68, 77, 38));
	elem.putColor(new CColor(254, 250, 201));
	elem.putColor(new CColor(165, 181, 146));
	elem.putColor(new CColor(243, 164, 71));
	elem.putColor(new CColor(231, 188, 41));
	elem.putColor(new CColor(208, 146, 167));
	elem.putColor(new CColor(156, 133, 192));
	elem.putColor(new CColor(128, 158, 194));
	elem.putColor(new CColor(142, 88, 182));
	elem.putColor(new CColor(127, 111, 111));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Solstice';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(79, 39, 28));
	elem.putColor(new CColor(231, 222, 201));
	elem.putColor(new CColor(56, 145, 167));
	elem.putColor(new CColor(254, 184, 10));
	elem.putColor(new CColor(195, 45, 46));
	elem.putColor(new CColor(132, 170, 51));
	elem.putColor(new CColor(150, 67, 5));
	elem.putColor(new CColor(71, 90, 141));
	elem.putColor(new CColor(141, 199, 101));
	elem.putColor(new CColor(170, 138, 20));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Technic';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(59, 59, 59));
	elem.putColor(new CColor(212, 210, 208));
	elem.putColor(new CColor(110, 160, 176));
	elem.putColor(new CColor(204, 175, 10));
	elem.putColor(new CColor(141, 137, 164));
	elem.putColor(new CColor(116, 133, 96));
	elem.putColor(new CColor(158, 146, 115));
	elem.putColor(new CColor(126, 132, 141));
	elem.putColor(new CColor(0, 200, 195));
	elem.putColor(new CColor(161, 22, 224));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Trek';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(78, 59, 48));
	elem.putColor(new CColor(251, 238, 201));
	elem.putColor(new CColor(240, 162, 46));
	elem.putColor(new CColor(165, 100, 78));
	elem.putColor(new CColor(181, 139, 128));
	elem.putColor(new CColor(195, 152, 109));
	elem.putColor(new CColor(161, 149, 116));
	elem.putColor(new CColor(193, 117, 41));
	elem.putColor(new CColor(173, 31, 31));
	elem.putColor(new CColor(255, 196, 47));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Urban';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(66, 68, 86));
	elem.putColor(new CColor(222, 222, 222));
	elem.putColor(new CColor(83, 84, 138));
	elem.putColor(new CColor(67, 128, 134));
	elem.putColor(new CColor(160, 77, 163));
	elem.putColor(new CColor(196, 101, 45));
	elem.putColor(new CColor(139, 93, 61));
	elem.putColor(new CColor(92, 146, 181));
	elem.putColor(new CColor(103, 175, 189));
	elem.putColor(new CColor(194, 168, 116));
	g_oUserColorScheme.push(elem);
	elem = new CAscColorScheme();
	elem.name = 'Verve';
	elem.putColor(new CColor(0, 0, 0));
	elem.putColor(new CColor(255, 255, 255));
	elem.putColor(new CColor(102, 102, 102));
	elem.putColor(new CColor(210, 210, 210));
	elem.putColor(new CColor(255, 56, 140));
	elem.putColor(new CColor(228, 0, 89));
	elem.putColor(new CColor(156, 0, 127));
	elem.putColor(new CColor(104, 0, 127));
	elem.putColor(new CColor(0, 91, 211));
	elem.putColor(new CColor(0, 52, 158));
	elem.putColor(new CColor(23, 187, 253));
	elem.putColor(new CColor(255, 121, 194));
	g_oUserColorScheme.push(elem);

var g_oUserTexturePresets = [
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    ""
];

var g_sWordPlaceholderImage = "";




	var g_aTextArtPresets = [
		"textNoShape",
		"textPlain",
		"textStop",
		"textTriangle",
		"textTriangleInverted",
		"textChevron",
		"textChevronInverted",
		"textRingInside",
		"textRingOutside",
		"textArchUpPour",
		"textArchDownPour",
		"textCirclePour",
		"textButtonPour",
		"textCurveUp",
		"textCurveDown",
		"textCanUp",
		"textCanDown",
		"textWave1",
		"textWave2",
		"textDoubleWave1",
		"textWave4",
		"textInflate",
		"textDeflate",
		"textInflateBottom",
		"textDeflateBottom",
		"textInflateTop",
		"textDeflateTop",
		"textDeflateInflate",
		"textDeflateInflateDeflate",
		"textFadeRight",
		"textFadeLeft",
		"textFadeUp",
		"textFadeDown",
		"textSlantUp",
		"textCascadeUp",
		"textCascadeDown",
		"textArchUp",
		"textArchDown",
		"textCircle",
		"textButton"
	];



	function fSaveStream(oStream, nLength) {
		/*var aData = oStream.data.slice(oStream.cur, oStream.cur + nLength);
		var sData = "XLSY;;";
		sData += (nLength + ";");
		sData += AscCommon.Base64Encode(aData,aData.length, 0);
		var nCRC32 = AscCommon.g_oCRC32.Calculate_ByString(sData, sData.length);
		return {data: sData, crc32: nCRC32};*/
		return undefined;
	}

    //----------------------------------------------------------export----------------------------------------------------


  window['AscCommon'] = window['AscCommon'] || {};
  window['AscCommon'].g_oAutoShapesGroups = g_oAutoShapesGroups;
  window['AscCommon'].g_oAutoShapesTypes = g_oAutoShapesTypes;
  window['AscCommon'].g_oStandartColors = g_oStandartColors;
  window['AscCommon'].GetDefaultColorModsIndex = GetDefaultColorModsIndex;
  window['AscCommon'].GetDefaultMods = GetDefaultMods;
  window['AscCommon'].g_oUserColorScheme = g_oUserColorScheme;
  window['AscCommon'].g_oUserTexturePresets = g_oUserTexturePresets;
  window['AscCommon'].g_sWordPlaceholderImage = g_sWordPlaceholderImage;
  window['AscCommon'].g_aTextArtPresets = g_aTextArtPresets;
  window['AscCommon'].sChartStyles = "";




	window['AscCommon'].g_oChartStyles = window['AscCommon']['g_oChartStyles'] || {};
	window['AscCommon']['g_oChartStyles'] = window['AscCommon'].g_oChartStyles;

	window['AscCommon'].g_oStylesBinaries = window['AscCommon']['g_oStylesBinaries'] || {};
	window['AscCommon']['g_oStylesBinaries'] = window['AscCommon'].g_oStylesBinaries;

	window['AscCommon'].g_oColorsBinaries = window['AscCommon']['g_oColorsBinaries'] || {};
	window['AscCommon']['g_oColorsBinaries'] = window['AscCommon'].g_oColorsBinaries;

	window['AscCommon'].g_oDataLabelsBinaries = window['AscCommon']['g_oDataLabelsBinaries'] || {};
	window['AscCommon']['g_oDataLabelsBinaries'] = window['AscCommon'].g_oDataLabelsBinaries;

	window['AscCommon'].g_oLegendBinaries = window['AscCommon']['g_oLegendBinaries'] || {};
	window['AscCommon']['g_oLegendBinaries'] = window['AscCommon'].g_oLegendBinaries;

	window['AscCommon'].g_oCatBinaries = window['AscCommon']['g_oCatBinaries'] || {};
	window['AscCommon']['g_oCatBinaries'] = window['AscCommon'].g_oCatBinaries;

	window['AscCommon'].g_oValBinaries = window['AscCommon']['g_oValBinaries'] || {};
	window['AscCommon']['g_oValBinaries'] = window['AscCommon'].g_oValBinaries;

	window['AscCommon'].g_oBarParams = window['AscCommon']['g_oBarParams'] || {};
	window['AscCommon']['g_oBarParams'] = window['AscCommon'].g_oBarParams;

	window['AscCommon'].g_oView3dBinaries = window['AscCommon']['g_oView3dBinaries'] || {};
	window['AscCommon']['g_oView3dBinaries'] = window['AscCommon'].g_oView3dBinaries;

	window['AscCommon'].g_oChartStylesIdMap = window['AscCommon']['g_oChartStylesIdMap'] || {};
	window['AscCommon']['g_oChartStylesIdMap'] = window['AscCommon'].g_oChartStylesIdMap;

	function fGetAttributeString(attribute) {
		if(Array.isArray(attribute)) {
			var sResult = "[";
			for(var nIdx = 0; nIdx < attribute.length; ++nIdx) {
				sResult += fGetAttributeString(attribute[nIdx]);
				if(nIdx < attribute.length - 1) {
					sResult += ", ";
				}
			}
			sResult += "]";
			return sResult;
		}
		var nParsedNum = parseInt(attribute);
		if(!isNaN(nParsedNum) && (!(typeof attribute === "string") || attribute === ("" + nParsedNum))) {
			return "" + attribute;
		}
		if(typeof attribute === "string") {
			return "\"" + attribute + "\"";
		}
		return "" + attribute;
	}
	function fGenerateScriptMap(sObjectName, oMap, bKeysAsIs) {
		var sMapScript = sObjectName + " = {};\n";
		var oKeysMap = {};
		for(var key in oMap) {
			if(oMap.hasOwnProperty(key)) {
				var sValue = fGetAttributeString(oMap[key]);
				if(!Array.isArray(oKeysMap[sValue])) { 
					oKeysMap[sValue] = [];
				}
				oKeysMap[sValue].push(key);
			}
		}
		for(var sValues in oKeysMap) {
			if(oKeysMap.hasOwnProperty(sValues)) {
				var aKeys = oKeysMap[sValues];
				for(var nKey = 0; nKey < aKeys.length; ++nKey) {
					var sKey = aKeys[nKey];
					if(!bKeysAsIs) {
						sMapScript += (sObjectName + "[" + fGetAttributeString(sKey) + "] = ");
					}
					else {
						sMapScript += (sObjectName + "[" + sKey + "] = ");
					}
				}
				sMapScript += (sValues + ";\n");
			}
		}
		sMapScript += "\n";
		return sMapScript;
	}
	function fGenerateStyles() {
		var sResultScript = "";
		sResultScript += fGenerateScriptMap("g_oDataLabelsBinaries", AscCommon.g_oDataLabelsBinaries);
		sResultScript += fGenerateScriptMap("g_oCatBinaries", AscCommon.g_oCatBinaries);
		sResultScript += fGenerateScriptMap("g_oValBinaries", AscCommon.g_oValBinaries);
		sResultScript += fGenerateScriptMap("g_oBarParams", AscCommon.g_oBarParams);
		sResultScript += fGenerateScriptMap("g_oView3dBinaries", AscCommon.g_oView3dBinaries);
		sResultScript += fGenerateScriptMap("g_oLegendBinaries", AscCommon.g_oLegendBinaries);
		sResultScript += fGenerateScriptMap("g_oStylesBinaries", AscCommon.g_oStylesBinaries);
		sResultScript += fGenerateScriptMap("g_oColorsBinaries", AscCommon.g_oColorsBinaries);
		sResultScript += fGenerateScriptMap("g_oChartStyles", AscCommon.g_oChartStyles, true);
		sResultScript += fGenerateScriptMap("g_oChartStylesIdMap", AscCommon.g_oChartStylesIdMap, true);
		return sResultScript;
	}
  window['AscCommon'].fSaveStream = fSaveStream;
  window['AscCommon'].fGenerateStyles = fGenerateStyles;

})(window);
